BIN = ./bin
PROGRAM = $(BIN)/mykit 
SRCDIRS = $(shell find ./src -maxdepth 1 -type d)
SRCEXTS = .c
INCLUDES = -I/usr/include -I./src -I./src/json
LIBS = -L/usr/lib64
CFLAGS = -std=c99 -g -Wall -O2 -finput-charset=UTF-8 -DTHREADSAFE=1 -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -U__STRICT_ANSI__
LDFLAGS = -lpthread -ldl
CC = gcc
SRCS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
OBJS = $(foreach x,$(SRCEXTS),$(patsubst %$(x),%.o,$(filter %$(x),$(SRCS))))
.PHONY : cleanall
all : $(PROGRAM)
objs : $(OBJS)
%.o : %.c
	$(CC) $(CFLAGS) -c $(@D)/$(<F) -o $(@D)/$(@F) ${INCLUDES}
$(PROGRAM) : $(OBJS)
	$(CC) -o $(PROGRAM) $(OBJS) ${LIBS} $(LDFLAGS)
rebuild: clean all
clean : 
	rm -f *.o 
cleanall: clean
	rm -f *.o 